package com.example.administrator.android2019.ch3Activity;

import android.content.Context;
import android.content.SharedPreferences;

import java.util.HashMap;

public class SPSaveQQ {
/**
 *  context 上下文对象
 *  name 账号
 *  pwd 密码
 *
 *
 * */
    public static boolean save(Context context, String name, String pwd) {

        SharedPreferences sp=context.getSharedPreferences("qq",Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=sp.edit();
        editor.putString("name",name);
        editor.putString("pwd",pwd);
        editor.commit(); //commit 提交
        return true;
    }

    public static HashMap<String, String> get(Context context) {
        HashMap<String,String> hashMap=new HashMap<String, String>();
        SharedPreferences sp=context.getSharedPreferences("qq",Context.MODE_PRIVATE);
        String name=sp.getString("name",null);
        String pwd=sp.getString("pwd",null);
        hashMap.put("name",name);
        hashMap.put("pwd",pwd);
        return hashMap;
    }
}
